/* 
 *	Copyright 2014  Yanqing Wu
 *		email: yqwu_yqwu@126.com
 *
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
*/

#pragma once

#include "StdCtrlSkin_BaseElt.h"

#include "StdCtrlSkin_Enums.h"
#include "StdCtrlSkinTable.h"

#include <fstream>

class CStdCtrlSkin;
class CStdCtrlSkinBg;

class CStdCtrlSkinWnd : public CStdCtrlSkin_BaseElt
{
protected:
	std::map<UINT, CStdCtrlSkinTable*> m_table_list;
	CStdCtrlSkinBg* m_bg;
	//	Back pointer to manager
	CStdCtrlSkin* m_pMgr;
	//	Controls managed in this window
	std::map<CString, CWnd*> m_ctrl_list;
	//	Name-Cell look up table
	std::map<CString, CStdCtrlSkinCell*> m_name2cell_list;

public:
	CString window_name;

public:
	virtual void InitDataElt(CStdCtrlSkin* pMgr);
	CStdCtrlSkinWnd(CStdCtrlSkin* pMgr=nullptr);
	CStdCtrlSkinWnd(CComPtr<IXMLDOMNode> spNode, CStdCtrlSkin* pMgr);
	virtual ~CStdCtrlSkinWnd(void);

	virtual void SetRect(CRect rect);

	virtual bool LogControl(CString ctrlName, CWnd* pCtrl);
	virtual bool UnlogControl(CWnd* pCtrl);

	virtual void DoLayOut(CRect rect);

	virtual HBITMAP GetBitmap(CSize size, HDC hDC);

	CString GetFilePath(void);

	virtual void SetBackColor(COLORREF color);

#ifdef __DUMPTEST
	virtual void Dump(std::ofstream& fio, CStdCtrlSkin_EnumDump type) override;
#endif

protected:
	bool LoadXmlNode(CComPtr<IXMLDOMNode> spNode);
	//	After load the window, generate data link only, currently
	virtual void PostLoading(void);
};

